package com.xiaoma.tpo.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.dto.ForcastQuestionDto;
import com.xiaoma.verbal.domain.FctQuestion;

/**
 * 机经预测dao
 * @author 1
 *
 */
@Repository
public class ForcastDao extends BaseDaoImpl<FctQuestion> {

	private static final Logger LOG = LoggerFactory.getLogger(FctQuestion.class);
	
	@SuppressWarnings("unchecked")
	public List<ForcastQuestionDto> findByFctId(Integer fctId) {
		String sql = "select a.question_id, b.content as question_title, b.audio_zip" +
				" from fct_question a, qu_question b" +
				" where a.question_id = b.id" +
				" and a.forecast_id = ?";
		
		LOG.info("SQL:{} PARAMS:{}", sql, fctId);
		List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(ForcastQuestionDto.class, getNameHandler()), fctId);
		return (List<ForcastQuestionDto>) result;
	}
}
